//
//  SecondViewController.m
//  13-简书
//
//  Created by dllo on 16/8/1.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "SecondViewController.h"
#import "MyTableViewCell.h"
#import "MyDirectionaryTableViewCell.h"
#import "myModel.h"
@interface SecondViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (nonatomic, strong) NSMutableArray *myArray;

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 自己的数据
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"];
    NSDictionary *dataDic = [NSDictionary dictionaryWithContentsOfFile:path];
    _myArray = [NSMutableArray array];
    for (NSDictionary *dic in dataDic[@"circleImage"]) {
        myModel *model = [[myModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [_myArray addObject:model];
    }
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    } else {
        return _myArray.count;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 1) {
        return 30;
    } else {
        return 0;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 120;
    } else {
        return 60;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"2"];
        return cell;
    } else {
        MyDirectionaryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"3"];
        myModel *model = _myArray[indexPath.row];
        cell.image_person1.image = [UIImage imageNamed:model.image_person1];
        cell.image_person.image = [UIImage imageNamed:model.image_person];
        cell.name.text = model.name;
        return cell;
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
